name: Docker Image CD

on:
  workflow_dispatch:
    inputs:
      tag:
        description: 'Docker Image tag'
        type: string
        required: false
        default: 'latest'
      first_number:
        description: 'First number'
        type: number
        required: true
      second_number:
        description: 'Second number'
        type: number
        required: true

jobs:
  deploy:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout
        uses: actions/checkout@v3

      - name: Login to Docker Hub
        uses: docker/login-action@v3
        with:
          username: ${{ secrets.DOCKER_USERNAME }}
          password: ${{ secrets.DOCKER_PASSWORD }}

      - name: Pull the Docker image
        run: docker pull ${{ secrets.DOCKER_USERNAME }}/tinkoff_hw1:${{ inputs.tag }}
      - name: Run Docker container and display result
        run: docker run ${{ secrets.DOCKER_USERNAME }}/tinkoff_hw1:${{ inputs.tag }} ${{ inputs.first_number }} ${{ inputs.second_number }}